package org.genntii.smcommon.result;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 封装分页查询结果
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PageResult<T> implements Serializable {

    private long total; //总记录数

    private ArrayList<T> records; //当前页数据集合

    public static <T> PageResult<T> build(ArrayList<T> object,long total){
        PageResult<T> pageResult = new PageResult<T>();
        pageResult.records = object;
        pageResult.total = total;
        return pageResult;
    }

}
